Yale Center for Global Change

Overview

  • Points
  • Vectors
  • Rasters
  • Workflow

Points

coords = data.frame(x=rnorm(100),y=rnorm(100))
sp = SpatialPoints(coords)
str(sp)
## Formal class 'SpatialPoints' [package "sp"] with 3 slots
##   ..@ coords     : num [1:100, 1:2] -0.739 -0.8968 -0.393 0.0962 -1.7668 ...
##   .. ..- attr(*, "dimnames")=List of 2
##   .. .. ..$ : NULL
##   .. .. ..$ : chr [1:2] "x" "y"
##   ..@ bbox       : num [1:2, 1:2] -2.57 -1.83 2.06 2.54
##   .. ..- attr(*, "dimnames")=List of 2
##   .. .. ..$ : chr [1:2] "x" "y"
##   .. .. ..$ : chr [1:2] "min" "max"
##   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
##   .. .. ..@ projargs: chr NA

Vectors (ShapeFiles)

za=getData('GADM', country='ZAF', level=1)
plot(za)

Vectors (ShapeFiles)

za
## class       : SpatialPolygonsDataFrame 
## features    : 9 
## extent      : 16.45189, 32.89125, -34.83514, -22.12503  (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## variables   : 13
## names       : OBJECTID, ID_0, ISO,       NAME_0, ID_1,       NAME_1, HASC_1, CCN_1, CCA_1,    TYPE_1, ENGTYPE_1, NL_NAME_1,         VARNAME_1 
## min values  :        1,  211, ZAF, South Africa,    1, Eastern Cape,  ZA.EC,    NA,    EC, Provinsie,  Province,          , Eastern Transvaal 
## max values  :        9,  211, ZAF, South Africa,    9, Western Cape,  ZA.WC,    NA,    WC, Provinsie,  Province,          ,          Wes-Kaap

Rasters

clim=getData('worldclim', var='bio', res=10) 
plot(clim[[1]])

Rasters

## class       : RasterStack 
## dimensions  : 900, 2160, 1944000, 19  (nrow, ncol, ncell, nlayers)
## resolution  : 0.1666667, 0.1666667  (x, y)
## extent      : -180, 180, -60, 90  (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
## names       :  bio1,  bio2,  bio3,  bio4,  bio5,  bio6,  bio7,  bio8,  bio9, bio10, bio11, bio12, bio13, bio14, bio15, ... 
## min values  :  -269,     9,     8,    72,   -59,  -547,    53,  -251,  -450,   -97,  -488,     0,     0,     0,     0, ... 
## max values  :   314,   211,    95, 22673,   489,   258,   725,   375,   364,   380,   289,  9916,  2088,   652,   261, ...

Workflow

alt text

Workflow

  • Download a global Maximum Temperature dataset
  • Crop it to a country you download
  • Calculate the overall range for each variable
  • Calculate the focal median with an 11x11 window
  • Create a transect across the region and extract the temperature data.

Using this tutorial

alt text